<?php

namespace app\validate;
use app\BaseValidate;
class AdminUser extends BaseValidate
{
    protected $rule = [
        'username'  => 'require|length:2,20|unique:admin_user',
        'password'   => 'noChs|length:6,20',
        'phone' =>'require|mobile|unique:admin_user',
        'sex' => 'require|in:0,1,2',
        'nickname'=>'require|length:2,20',
    ];

    protected $message  =   [
        'username.require' => '用户名必须',
        'username.length' => '用户名长度2至20个字符',
        'password.require' => '密码必须填写',
        'password.noChs' => '密码不能包含中文',
        'password.length' => '密码长度6至20个字符',
        'captcha.captcha' => '验证码有误!',
        'captcha.require' => '请输入验证码!',
        'phone.require' => '请填写手机号',
        'phone.mobile' => '手机号格式有误!',
        'sex.require' => '请选择性别',
        'sex.in' => '性别有误!',
        'username.unique' => '用户名不能重复',
        'phone.unique' => '手机号不能重复',
        'nickname.require' => '请填写昵称',
        'nickname.length' => '昵称长度2至20个字符',
    ];

    protected $scene = [
        'login'  =>  ['password','username'=>
            [
                'require',
                'length:2,20'
            ]
        ],
        'update' =>  ['username','phone','nickname','phone']
    ];
}
